using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
using TimeWar.Render;

namespace TimeWar
{
    /// <summary>
    /// This is the main type for your game
    /// </summary>
    public class TimeWar : FrameworkCore
    {
        #region Fields

        static GamePlayer singlePlayer = null;
        static GameLevel currentGameLevel = null;
        static BaseStageScreen currentStage = null;
        static VersusGameInfo versusGameInfo = null;

        #endregion

        #region Properties

        /// <summary>
        /// This is only player 1 in the game. never other player.
        /// </summary>
        public static GamePlayer SinglePlayer
        {
            get { return singlePlayer; }
            set { singlePlayer = value; }
        }

        /// <summary>
        /// This is current level in the game.
        /// </summary>
        public static GameLevel CurrentGameLevel
        {
            get { return currentGameLevel; }
            set { currentGameLevel = value; }
        }

        /// <summary>
        /// This is current stage in the game.
        /// </summary>
        public static BaseStageScreen CurrentStage
        {
            get { return currentStage; }
            set { currentStage = value; }
        }

        /// <summary>
        /// Information for versus play
        /// </summary>
        public static VersusGameInfo VersusGameInfo
        {
            get { return versusGameInfo; }
            set { versusGameInfo = value; }
        }

        #endregion

        /// <summary>
        /// Constructor.
        /// </summary>
        public TimeWar() : base()
        {
            //  Set to window title name
            Window.Title = "Time War";

            //  Initialize a graphics information
            GraphicsInfo graphicsInfo = new GraphicsInfo();

#if XBOX
            graphicsInfo.screenWidth = (int)ViewerWidth.Width1080;
            graphicsInfo.screenHeight = (int)ViewerHeight.Height1080;
#else
            graphicsInfo.screenWidth = (int)ViewerWidth.Width720;
            graphicsInfo.screenHeight = (int)ViewerHeight.Height720;
#endif
            //  Set to shader info
            graphicsInfo.pixelShaderProfile = ShaderProfile.PS_2_0;
            graphicsInfo.vertexShaderProfile = ShaderProfile.VS_2_0;

            //  Must be call in this constructor
            ChangeGraphics(graphicsInfo);  
        }

        /// <summary>
        /// Allows the game to perform any initialization it needs to 
        /// before starting to run.  This is where it can query for any required services
        /// and load any non-graphics related content.  Calling base.Initialize will 
        /// enumerate through any components and initialize them as well.
        /// </summary>
        protected override void Initialize()
        { 
            base.Initialize();
            
            //  Initialize sound engine
            GameSound.Initialize();

            //  Create and set a startup screen...
            //  If you want to change startup screen, 
            //  change to new FirstStageScreen, etc.
            ScreenManager.AddScreen(new MainMenuScreen(), true);
        }


        internal static void ExitAccepted(object sender, EventArgs e)
        {
            //  Exit this program
            FrameworkCore.Game.Exit();
        }

    }
}
